<?php

namespace App\Http\Controllers\Api\V1\Site;

use Illuminate\Http\Request;
use Biz\Requests\Site\SiteWelcomeRequest;
use Biz\Services\Site\SiteWelcomeService;
use Biz\Resources\Site\SiteWelcomeResource;
use Laravel\Lumen\Routing\Controller as BaseController;

/**
 * WelcomeController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class WelcomeController extends BaseController
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * WelcomeController constructor.
     *
     * @param SiteWelcomeService $service
     */
    public function __construct(SiteWelcomeService $service)
    {
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function get(Request $request)
    {
        $welcome = $this->service->get($request);

        return new SiteWelcomeResource($welcome);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param SiteWelcomeRequest $request
     *
     * @return \Illuminate\Http\Response
     */
    public function save(SiteWelcomeRequest $request)
    {
        $welcome = $this->service->save($request);

        return new SiteWelcomeResource($welcome);
    }
}
